<?php
namespace Admin\Controller;

use Common\Controller\AdminbaseController;

class LockController extends AdminbaseController{
	
	//智能锁列表
	public function index(){
	    $Lock  = M('Lock');
        
	    $count = $Lock->count();
        
        $page  = $this->page($count, 8);
		$list = $Lock->limit($page->firstRow, $page->listRows)->order('box_id,lock_number asc')->select();
        $this->assign('list',$list);
        $this->assign("page", $page->show('Admin'));
       
        $this->display();
	}

	//二维码下载
	public function down_qrcode(){
		header("Content-type: application/octet-stream");  
		$Lock       = D('lock');
		$lock_id    = (int)($_GET['id']);

		$qrcode_path = $Lock->getQrcodePath($lock_id);
		
		$file = $qrcode_path;  
		
		header('Content-Disposition: attachment; filename="' . basename($file) . '"');  
		header("Content-Length: ". filesize($file));  
		readfile($file); 
	}


}